package com.gitee.feizns.quickstart.validation.constraints;

import com.gitee.feizns.quickstart.validation.validator.NotContainsNullConstraintValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Array;
import java.util.Collection;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;

/**
 * 验证数组{@link Array}或集合{@link Collection}不能包含空
 * @author feizns
 * @since 2023/04/11
 */
@Target({ FIELD, PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = NotContainsNullConstraintValidator.class)
public @interface NotContainsNull {

    /**
     * 错误消息模板
     * <p>
     *     默认消息先到 {@code 'resource:/ValidateMessages.properties'}文件中获取
     * </p>
     * @return {@link String}
     */
    String message() default "{com.gitee.feizns.quickstart.validation.constraints.NotContainsNull.message}";

    /**
     * 分组
     * groups 和 payload是验证必带的参数
     * @return {@link Class}
     */
    Class<?>[] groups() default {};

    /**
     * @see Payload
     * @return {@link Payload}
     */
    Class<? extends Payload>[] payload() default {};

}
